package com.wh.user.controller;

import com.wh.user.dto.SmsCodeDto;
import com.wh.user.service.IVerifyCodeService;
import com.wh.basic.vo.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 验证码接口
 * 1.图形验证码接口
 * 2.手机验证码接口
 */
@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    @GetMapping("/image/{key}")
    public AjaxResult imageVerifyCode(@PathVariable("key") String key){
        String base64Str = verifyCodeService.imageVerifyCode(key);
        System.out.println(base64Str);
        return AjaxResult.me().setResultObj(base64Str); 
    }

    @PostMapping("/smsCode")
    public AjaxResult sendSms(@RequestBody SmsCodeDto smsCodeDto){
        verifyCodeService.phoneVerifyCode(smsCodeDto);
        return AjaxResult.me();
    }


    /**
     * 微信绑定用户时的手机验证码
     * @param smsCodeDto
     * @return
     */
    @PostMapping("/binderSmsCode")
    public AjaxResult binderSmsCode(@RequestBody SmsCodeDto smsCodeDto ){
        verifyCodeService.binderVerifyCode(smsCodeDto);
        return AjaxResult.me();
    }



}